package com.apes.framework.plugin.websocket;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * 功能：消息发布者
 *
 * @author xul
 * @create 2018-06-30 17:53
 */
@Service
public class WsPublisher {

    @Autowired
    private StringRedisTemplate template;

    public void publish(WsMessage wsMessage) {
        template.convertAndSend("ws:topic", JSON.toJSONString(wsMessage));
    }
}
